<?php

/*
* class to handle site configuration
*/
class Config
{
	private static $instance;
	private $_configFile;
	
	/*
	* private constructor
	* load the configuration file
	*/
	private function __construct()
	{
		$this->_configFile = simplexml_load_file("./conf.xml");
	}

	public static function getInstance()
	{
		if(!isset(self::$instance))
		{
			$object= __CLASS__;
			self::$instance=new $object;
		}
		return self::$instance;
	}

	/* 
	*  get a config value from the config file - using xpath.
	*/
	function get($keyName)
	{
		$res = $this->_configFile->xpath($keyName);
		if(!isset($res) || !isset($res[0]) || !isset($res[0][0]))
			return "";
		return (string)$res[0][0];
	}
	
	function getConfig($keyName)
	{
		$res = $this->_configFile->xpath($keyName);
		return $res;
	}	
}

?>